<template>
	<view class="search-hot-list-container">
		<!-- 标题 -->
		<view class="search-hot-title">全网技术 一网打尽</view>
		<block v-for="(item, index) in hotList" :key="index">
			<view class="search-hot-item" @click="onItemClick(item, index)">
				<hot-ranking :ranking="index + 1"></hot-ranking>
				<text class="title line-clamp">{{ item.label }}</text>
				<image v-if="index <= 2" class="search-hot-icon" src="/static/images/hot-icon.png" />
			</view>
		</block>
	</view>
</template>

<script>
	import { _getSeachHotList } from 'api/search.js'
	import { mapState } from 'vuex';
	export default {
		name: "search-hot-list",
		data() {
			return {
				hotList: [] // 数据
			};
		},
		methods: {
			async getSeachHotList() {
				const { data: res } = await _getSeachHotList()
				this.hotList = res.list
				console.log(this.hotList)
			},
			onItemClick(item, index) {
				this.$emit('onSearch', item.label);
			}
		},
		created() {
			this.getSeachHotList()
		},
		computed: {
		}
	}
</script>

<style lang="scss">
	.search-hot-list-container {
		.search-hot-title {
			font-weight: bold;
			font-size: $uni-font-size-base;
			color: $uni-text-color-hot;
			padding: 0 12px $uni-spacing-col-lg 12px;
			margin: 0 -12px $uni-spacing-col-lg -12px;
			box-shadow: 2px 2px 5px 1px rgba(143, 143, 143, 0.1);
		}

		.search-hot-item {
			display: flex;
			padding: 10px;
			.title {
				color: $uni-text-color;
				font-size: $uni-font-size-base;
				margin: 0 $uni-spacing-row-base;
			}

			.search-hot-icon {
				width: 14px;
				height: 14px;
			}
		}
	}
</style>
